import { BufferGeometry, Color, Line, LineBasicMaterial, SplineCurve, Vector2 } from "three";
import Tank from "./Mesh/Tank";
export default class PlayerController {

    tank: Tank;

    public constructor(tank: Tank) {
        this.tank = tank;

        this.init();
    }

    private init() {
        const { tank } = this;

        document.onkeydown = function (e) {
            var keyNum = e.keyCode

            if (keyNum == 87) {//W
                tank.move(1);
            }
            if (keyNum == 83) {//N
                tank.move(-1);
            }
            if (keyNum == 65) {//A
                tank.rot(1);
            }
            if (keyNum == 68) {//D
                tank.rot(-1);
            }
        }

        document.onkeyup = function (e) {
            var keyNum = e.keyCode

            if (keyNum == 87) {//W
                tank.move(0);
            }
            if (keyNum == 83) {//N
                tank.move(0);
            }
            if (keyNum == 65) {//A
                tank.rot(0);
            }
            if (keyNum == 68) {//D
                tank.rot(0);
            }
        }
    }

}